package encaps.utils.rendering;

import encaps.resources.Response;
import static encaps.utils.html.HTML.*;
import encaps.utils.html.HTMLElement;
import encaps.utils.html.HTMLElementSequence;
import org.jdom.Element;

public class JavascriptButtonFactory extends ButtonFactory {

    @Override
    public HTMLElement renderField(Element e, boolean edit) {
        HTMLElementSequence result = new HTMLElementSequence();
        HTMLElement button = new HTMLElement(INPUT);
        String label = e.getChildTextTrim(Response.LABEL);
        String key = e.getChildTextTrim(Response.KEY);
        String value = e.getChildTextTrim(Response.VALUE);


        button.addAttribute(TYPE, BUTTON);
        button.addAttribute(ONCLICK, value);
        button.addAttribute(VALUE, label);

        result.addContent(HTMLElement.createBr());
        result.addContent(button);
        //result.addContent(HTMLElement.createBr());
        return result;

    }
}